package com.loan.psychicloan.imageloder;

import android.widget.ImageView;

/**
 * Created by watilion on 2017/12/21 0021.
 */

public class ImageLoader {

    private int type;//(大、中、小图)
    private String url;//图片的url
    private int placeHolder;//加载图片失败时
    private ImageView imageView;//imageview instantce
    private int wifiStrategy;//加载模式，是否有wifi信号

    private ImageLoader(Builder builder){
        this.type = builder.type;
        this.url = builder.url;
        this.placeHolder = builder.placeHolder;
        this.imageView = builder.imageView;
        this.wifiStrategy = builder.wifiStrategy;
    }

    public int getType() {
        return type;
    }

    public String getUrl() {
        return url;
    }

    public int getPlaceHolder() {
        return placeHolder;
    }

    public ImageView getImageView() {
        return imageView;
    }

    public int getWifiStrategy() {
        return wifiStrategy;
    }

    public static class Builder{
        private int type;
        private String url;
        private int placeHolder;
        private ImageView imageView;
        private int wifiStrategy;

        public Builder(){
            this.type = ImageLoaderUtil.PIC_SMALL;
            this.url = "";
            this.placeHolder = ImageLoaderUtil.LOAD_STRATEGY_NORMAL;
        }
        public Builder type(int type){
            this.type = type;
            return this;
        }

        public Builder url(String url){
            this.url = url;
            return this;
        }

        public Builder placeHolder(int placeHolder){
            this.placeHolder = placeHolder;
            return this;
        }

        public Builder imageView(ImageView imageView){
            this.imageView = imageView;
            return this;
        }

        public Builder strategy(int strategy){
            this.wifiStrategy = strategy;
            return this;
        }

        public ImageLoader build(){
            return new ImageLoader(this);
        }
    }
}
